import store from "../store/store.js";
import api from "./api.js";


export function getUserNickname() {
    return new Promise((resolve, reject) => {
        api.get('/common/getUserNickname').then(res => {
            if (res.data) {
                store.commit('setUserNickname', res.data)
            }
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    });
}
export function searchPets(searchText, pageNo, pageSize) {
    return new Promise((resolve, reject) => {
        api.get('/common/searchPets', {
            params: {
                search_text: searchText,
                page_no: pageNo,
                page_size: pageSize
            }
        }).then(res => {
            resolve(res)
        }).catch(err => {
            reject(err)
        })
    });
}